package cn.easy.rpc.core;

import lombok.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.io.Serializable;
import java.util.List;
import java.util.UUID;

/**
 * @author zwb
 * @create 2020-09-05 21:10
 **/
@Data
public class ServiceRegistrar implements Serializable {

    private static final Log logger = LogFactory.getLog(ServiceRegistrar.class);

    public static final String REGISTRAR_HOST = "rpc.registrar.host";
    public static final String REGISTRAR_PORT = "rpc.registrar.port";
    public static final String REGISTRAR_APP_GROUP = "rpc.registrar.group";
    public static final String REGISTRAR_APP_NAME = "rpc.registrar.name";
    public static final String REGISTRAR_VERSION = "rpc.registrar.version";

    private final String serviceId;

    public ServiceRegistrar() {
        this.serviceId = UUID.randomUUID().toString().replace("-", "");
    }

    private String host;
    private Integer port;
    private String group;
    private String name;
    private Double version;
    private List<ServiceSchema> services;


    public void print() {
        logger.info("---------------registrar info---------------");
        logger.info("serviceId：" + serviceId);
        logger.info("port：" + port);
        logger.info("name：" + name);
        logger.info("group：" + group);
        logger.info("services：(" + services.size() + ") detail:" + services.toString());
        logger.info("--------------------------------------------");
    }
}
